package com.hsmpay.mobile.dao.trans.impl;

import com.hsmpay.common.dao.Impl.BaseDaoSupport;
import com.hsmpay.mobile.dao.trans.SSBindCardsDao;
import com.hsmpay.mobile.pojo.trans.SSBindCards;
import com.hsmpay.mobile.pojo.trans.SSBindCardsExample;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

/**
 * Created by zhy on 16/3/28.
 *
 * 银行卡绑定dao
 */
@Repository("ssBindCardsDao")
public class SSBindCardsDaoImpl extends BaseDaoSupport<SSBindCards, Long> implements SSBindCardsDao<SSBindCards, Long> {
	public SSBindCardsDaoImpl() {
        super();
    }

    public void insert(SSBindCards record) {
        getSqlMapClientTemplate().insert("sSBindCardsSqlMap.insert", record);
    }

    public int updateByPrimaryKey(SSBindCards record) {
        int rows = getSqlMapClientTemplate().update("sSBindCardsSqlMap.updateByPrimaryKey", record);
        return rows;
    }

    public int updateByPrimaryKeySelective(SSBindCards record) {
        int rows = getSqlMapClientTemplate().update("sSBindCardsSqlMap.updateByPrimaryKeySelective", record);
        return rows;
    }

    public List selectByExample(SSBindCardsExample example) {
        List list = getSqlMapClientTemplate().queryForList("sSBindCardsSqlMap.selectByExample", example);
        return list;
    }

    public SSBindCards selectByPrimaryKey(Long id) {
        SSBindCards key = new SSBindCards();
        key.setId(id);
        SSBindCards record = (SSBindCards) getSqlMapClientTemplate().queryForObject("sSBindCardsSqlMap.selectByPrimaryKey", key);
        return record;
    }

    public int deleteByExample(SSBindCardsExample example) {
        int rows = getSqlMapClientTemplate().delete("sSBindCardsSqlMap.deleteByExample", example);
        return rows;
    }

    public int deleteByPrimaryKey(Long id) {
        SSBindCards key = new SSBindCards();
        key.setId(id);
        int rows = getSqlMapClientTemplate().delete("sSBindCardsSqlMap.deleteByPrimaryKey", key);
        return rows;
    }

    public int countByExample(SSBindCardsExample example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("sSBindCardsSqlMap.countByExample", example);
        return count.intValue();
    }

    public int updateByExampleSelective(SSBindCards record, SSBindCardsExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("sSBindCardsSqlMap.updateByExampleSelective", parms);
        return rows;
    }

    public int updateByExample(SSBindCards record, SSBindCardsExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("sSBindCardsSqlMap.updateByExample", parms);
        return rows;
    }

    private static class UpdateByExampleParms extends SSBindCardsExample {
        private Object record;

        public UpdateByExampleParms(Object record, SSBindCardsExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }

	@Override
	public List selectBindCardsListByUserId(Long userId) {
		List list = getSqlMapClientTemplate().queryForList("sSBindCardsSqlMap.selectBindCardsListByUserId", userId);
		return list;
	}
}
